/**
 * @date 2006-2-17 14:55:31
 *
 */
package org.nanhill.moo.domain.permission;

/**
 * Permission is Operation Resource mapping.
 * 
 * @author alin [xalinx at gmail dot com]
 * 
 */
public class Permission {
	private long id;

	/**
	 * permission name
	 */
	private String name;

	private String operation;

	private String resource;

	/**
	 * @return
	 */
	public String getOperation() {
		return operation;
	}

	public void setOperation(String operation) {
		this.operation = operation;
	}

	public String getResource() {
		return resource;
	}

	public void setResource(String resource) {
		this.resource = resource;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Permission() {
	}

	public Permission(String name) {
		this.name = name;
	}

	@Override
	public boolean equals(Object other) {
		if (other == this)
			return true;
		if (!(other instanceof Permission))
			return false;
		final Permission per = (Permission) other;
		return (operation == null ? per.getOperation() == null : operation
				.equals(per.getOperation()))
				&& (resource == null ? per.getResource() == null : resource
						.equals(per.getResource()));
	}

	// @Override
	// public int hashCode() {
	// return 29 * resource.hashCode() + operation.hashCode();
	// }

	@Override
	public String toString() {
		return "{name:" + name + ",operation:" + operation + ",resource:"
				+ resource + "}";
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}
}
